package com.fjd.mapper;

import com.fjd.entity.SalesDetail;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface SalesDetailMapper {

    @Select("select * from sales_detail where order_id = #{orderId}")
    List<SalesDetail> getOrderDetail(String orderId);

    @Insert("insert into sales_detail (order_id, product_id, warehouse_code, subtotal, product_sales_quantity, total_amount ,address_id,status) " +
            "VALUES (#{orderId},#{productId},#{warehouseCode},#{subtotal},#{productSalesQuantity},#{totalAmount},#{addressId},#{status})")
    void insert(SalesDetail salesDetail);

    @Select("select * from sales_detail where order_id = #{orderId}")
    List<SalesDetail> getByOrderId(String orderId);

    @Delete("delete from sales_detail where order_id = #{orderId}")
    void deleteByOrderId(String orderId);

    @Update("update sales_detail set address_id = #{addressId} where order_id = #{orderId}")
    void setAddress(String addressId, String orderId);
}
